<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>NumCpp: Building</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="NumCppLogoDoxygen.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">NumCpp
   &#160;<span id="projectnumber">2.2.0</span>
   </div>
   <div id="projectbrief">ATemplatizedHeaderOnlyC++ImplementationofthePythonNumPyLibrary</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('md__mnt_c__github__num_cpp_docs_markdown__building.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Building </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h2>A NumCpp "Hello World" example</h2>
<p>This example assumes you have followed the steps for installing NumCpp on your system. You will also need to have CMake installed.</p>
<h3>1. Source File</h3>
<p><b>main.cpp</b></p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="_num_cpp_8hpp.html">NumCpp.hpp</a>&quot;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;cstdlib&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main()</div><div class="line">{</div><div class="line">    <span class="keyword">auto</span> a = nc::random::randInt&lt;int&gt;({10, 10}, 0, 100);</div><div class="line">    std::cout &lt;&lt; a;</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> EXIT_SUCCESS;</div><div class="line">}</div></div><!-- fragment --><h3>2. CMakeLists.txt file</h3>
<div class="fragment"><div class="line">cmake_minimum_required(VERSION 3.14)</div><div class="line"></div><div class="line">project(&quot;HelloWorld&quot; CXX)</div><div class="line"></div><div class="line">add_executable(${PROJECT_NAME} main.cpp)</div><div class="line"></div><div class="line">find_package(NumCpp 2.1.0 REQUIRED)</div><div class="line">target_link_libraries(${PROJECT_NAME}</div><div class="line">    NumCpp::NumCpp</div><div class="line">)</div></div><!-- fragment --><h3>3. Build</h3>
<p><b>SRC_DIRECTORY</b> = directory containing <code>main.cpp</code> and <code>CMakeLists.txt</code> files</p>
<div class="fragment"><div class="line">&gt;&gt; cd &lt;SRC_DIRECTORY&gt;</div><div class="line">&gt;&gt; mkdir build</div><div class="line">&gt;&gt; cd build</div><div class="line">&gt;&gt; cmake ..</div><div class="line">&gt;&gt; cmake --build . --config Release</div></div><!-- fragment --><h3>4. Run</h3>
<h4>Linux</h4>
<div class="fragment"><div class="line">&gt;&gt; ./HelloWorld</div></div><!-- fragment --><h4>Windows</h4>
<div class="fragment"><div class="line">&gt;&gt; HelloWorld.exe</div></div><!-- fragment --><h3>Alternative</h3>
<p><b>NumCpp</b> is a header only library so you can of course simply add the NumCpp include directory to your build system's include directories and build that way. However, <code>find_package(NumCpp)</code> takes care of finding and linking in the <b>Boost</b> headers automatically, so if you add the NumCpp headers manually you will need to manually include the <b>Boost</b> headers as well. </p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
